'use strict';

function compute_median(collection) {
  let result = [];
  let arr = collection.sort((a,b)=>a-b);
 

  let m = arr.length/2;
  if(arr.length%2 === 0){
    result =( arr[m]+arr[m-1])/2;
  }else{
    result = arr[parseInt(m)];
  }
  console.log(result);
  return result;
  //在这里写入代码
}
 var collection_a = [1, 1, 1, 2, 3];
 var collection_b = [1, 1, 2, 3];
 var collection_c = [1, 4, 6, 2, 3, 10, 9, 8, 11, 20, 19, 30];
//  let cct = compute_median(collection);
 compute_median(collection_a);
 compute_median(collection_b);
 compute_median(collection_c);
 
module.exports = compute_median;


